#version 330 core
out vec4 FragColor;

in vec3 Normal;
in vec3 Position;

uniform vec3 cameraPos;
uniform samplerCube skybox;
void main()
{
	//FragColor = texture(texture1, TexCoords);
	//反射 reflect
//	vec3 I = normalize(Position - cameraPos);
//	vec3 R = reflect(I, normalize(Normal));
//	FragColor = vec4(texture(skybox, R).rgb, 1.0);
	
	//折射 refract   （需要在光线离开物体的时候再次折射，现在只是单面折射(Single-side Refraction)）
	float ratio = 1.00 / 1.52;//折射率
	vec3 I = normalize(Position - cameraPos);
	vec3 R = refract(I, normalize(Normal), ratio);
	FragColor = vec4(texture(skybox, R).rgb, 1.0);
}